﻿using DesignModeConsole.行为型.状态模式.MarioSample;

namespace DesignModeConsole.行为型.状态模式;

public class StateService : IService
{
    public void Main()
    {
        // 分支逻辑法
        var mario = new MarioStateMachine1();
        mario.ObtainMushRoom();
        var score = mario.Score;
        var state = mario.CurrentState;
        Console.WriteLine($"当前分数：{score} 当前状态是：{state}");

        // 查表法
        var mario2 = new MarioStateMachine2();
        mario2.ObtainMushRoom();
        var score2 = mario2.Score;
        var state2 = mario2.State;
        Console.WriteLine($"当前分数：{score2} 当前状态是：{state2}");

        // 状态模式
        var mario3 = new MarioStateMachine3();
        mario3.ObtainMushRoom();
        var score3 = mario3.Score;
        var state3 = mario3.CurrentState.GetName();
        Console.WriteLine($"当前分数：{score3} 当前状态是：{state3}");

        mario3.ObtainCape();
        var score4 = mario3.Score;
        var state4 = mario3.CurrentState.GetName();
        Console.WriteLine($"当前分数：{score4} 当前状态是：{state4}");
    }
}